<include file="Public/head"/>
<style type="text/css">
    .focus-btn, .new_btn {
        width: 80px;
        border-radius: 3px;
        color: #fff;
        margin-left: 7px;
        padding: 3px;
        background-color: #20ab4f;
        border: medium none;
        float: left;
    }

    .new_btn {
        padding: 3px;
    }

    .chenggong1 .paidan {
        padding-top: 30px;
    }

    .paidan h3 {
        font-size: 16px;
        color: #000;
        margin-bottom: 30px;
    }

    input[name="aid"], input[name="name"], input[name="emp_user"] {
        border: 1px solid #d7d7d7;
        float: left;
        height: 24px;
        line-height: 24px;
        margin: 0 10px 10px 0;
        text-align: center;
        width: 150px;
    }

    #status {
        -moz-appearance: none;
        background: rgba(0, 0, 0, 0) url("{:get_style_cdnurl()}/paimai/yunying/images/sanjiao.jpg") no-repeat scroll 130px 5px;
        border: 1px solid #d7d7d7;
        color: #666;
        float: left;
        font-family: "微软雅黑";
        height: 26px;
        line-height: 26px;
        margin: 0 10px 0px 0;
        text-align: left;
        width: 154px;
    }

    .tanShang .daiJingW .tipmsg {
        font-size: 14px;
        margin-left: 25%;
    }
</style>
</head>
<include file="Public/common_header"/>
<div class="mian">
    <include file="Public/sidebar" menu="clcwht.wdhdgl"/>

    <div class="mianR">

        <div class='clearfix' style="margin: 12px 0;">
            <form id="searchFrom">
                <input type="text" name="aid" placeholder="请输入活动ID" class=""/>
                <input type="text" name="name" placeholder="请输入活动名称关键字" class=""/>
                <input type="text" name="emp_user" placeholder="请输入创建用户" class=""/>
                <input type="text" name="start_time" placeholder="创建开始时间" value="" class="xiaci xin-text1"
                       id="start_time" readonly/>
                <input type="text" name="end_time" placeholder="创建结束时间" value="" class="xiaci xin-text1"
                       id="end_time" readonly/>
                <select name="status" id="status">
                    <option value="0">全部状态</option>
                    <option value="1">已上线</option>
                    <option value="2">已下线</option>
                </select>
            </form>
            <div style="float:left;width:100%;height:30px;padding-top: 8px;">
                <input type="button" value="筛选" name="focus_search" class="focus-btn"/>
                <input type="button" value="新建活动" id="create_new" class="new_btn"/>
            </div>
        </div>
        <div class="yunBei"></div>
        <div class="yuList">
            <div class="listBox" id="listBox"></div>
        </div>
    </div>
    <!--上下线操作弹出窗口-->
    <div class="tanShang set_activity_status" style="display:none">
        <h3>活动设置</h3>
        <ul class="daiJingW">
            <li class="clearfix tipmsg"></li>
            <li class="clearfix">
                <input type="hidden" name="activity_id" id="activity_id">
                <input type="hidden" name="activity_status" id="activity_status">
                <input type="button" value="确定" class="queding" id="qd_set_activity_status"/>
                <input type="button" value="取消" class="quxiao"/>
            </li>
        </ul>
    </div>
    <div class="clear"></div>
    <script type="text/javascript">

        function set_activity_status(activityId, activityStatus) {
            var activityStatusName = '';
            if (activityStatus == 2) {
                activityStatusName = '下线';
            } else {
                activityStatusName = '上线';
            }
            var str = '确定将活动设置为 <b style="color:red">' + activityStatusName + '</b> 状态吗？';
            $('.tipmsg').html(str);
            $('#activity_id').val(activityId);
            $('#activity_status').val(activityStatus);
            $('.set_activity_status').show();
        }

        $('#qd_set_activity_status').click(function () {
            var activityId = $('#activity_id').val();
            var activityStatus = $('#activity_status').val();
            var post_data = {
                'activityId': activityId,
                'activityStatus': activityStatus
            }
            $(".yunBei").css("display", "block").unbind('click')
            $(".loading").fadeIn();
            $.post('/Activity/setActivityStatus', post_data, function (data) {
                if (data.code == 200) {
                    $('.set_user_status').hide();
                    btn_alert(data.msg);
                    setTimeout(function () {
                        window.location.reload();
                    }, 300);
                } else {
                    $(".loading").fadeOut();
                    shibai_alert(data.msg);
                }
            }, 'JSON');
        });

        $("#create_new").on('click', function () {
            window.location.href = "/Activity/addActivity"
        });
        get_list();

        function get_list() {
            var url = mkUrl();
            $.get("/Activity/activityList", url, function (data) {
                $("#listBox").html(data);
            }, "html");
        }

        function get_page(p) {
            var url = mkUrl();
            $.get("/Activity/activityList/" + encodeURI("p/" + p), url, function (data) {
                $("#listBox").html(data);
            }, "html");
        }

        $("input[name='focus_search']").click(function () {
            get_list();
        });

        function mkUrl() {
            var url = "";
            var aid = $("input[name='aid']").val();
            var name = $("input[name='name']").val();
            var emp_user = $("input[name='emp_user']").val();
            var start_time = $("input[name='start_time']").val();
            var end_time = $("input[name='end_time']").val();
            var status = $("#status").val();
            if (aid) {
                url += '&aid=' + aid;
            }
            if (name) {
                url += '&name=' + name;
            }
            if (emp_user) {
                url += '&emp_user=' + emp_user
            }
            if (start_time) {
                url += '&start_time=' + start_time;
            }
            if (end_time) {
                url += '&end_time=' + end_time;
            }
            if (status) {
                url += '&status=' + status;
            }
            return url;
        }

        $("#start_time").ymdateplugin({
            showTimePanel: true,
            changeMonth: true,
            changeYear: true
        });
        $("#end_time").ymdateplugin({
            showTimePanel: true,
            changeMonth: true,
            changeYear: true
        });
    </script>
    <include file="Public/foot"/>
